<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 字面量
        var proObj = {
            z:3
        };
        var obj = Object.create(proObj); //proObj是obj原型对象
        obj.x = 1;
        obj.y = 2;
        obj.z = 5;
        delete obj.z;
        obj.z;
        delete obj.z; //true 但是静默失败自身已经没有z了
        // delete obj.__proto__.z; //这样删除的是原型上的z
        obj.z; 

        
        // 构造器
        var Person = function(name,age){
            this.name = name;
            this.age = age;
        }
        Person.prototype.showInfo = function(){
            console.log("i`m"+thia.name+""+this.age+"years");
        }
        var boy = new Person("Jack",20);
        boy.__proto__ == Person.prototype;
        Person.prototype.__proto__ === Object.prototype;
        boy.__proto__.__proto__ === Object.prototype;
        Object.prototype; //null
        boy.__proto__.__proto__.__proto__; //null

        var arr1 = [1,2,3];
        arr1.__proto__ == Array.prototype;
        var arr2 = ["1"];
        arr2.__proto__ == Array.prototype;
        Array.prototype;
        arr1.push(4);
        arr1; //成功添加
        arr2.push("2");
        arr2; //成功添加
        // 改变原型对象的push方法
        Object.getOwnPropertyDescriptor(Array.prototype,"push");
        Array.prototype.push = function(){
            console.log("xx");
        }
        arr1.push(5); //xx arr调用的是原型链上的方法所以会改变push的功能
        arr1; //不变  
        arr2.push(5); //xx
        arr2;

        var Person = function(){

        }
        Person.prototype.showInfo = function(){}
        var boy = new Person();
        boy.__proto__ === Person.prototype; //t
        Person.prototype.__proto__ === Object.prototype; //t
        boy.__proto__.__proto__ === Object.prototype; //t

        var div = document.createElement("div");
        document.body.appendChild(div);
        div.__proto__ === HTMLDivElement.prototype;
        div.__proto__.__proto__ === HTMLElement.prototype;
        HTMLElement.prototype.__proto__ //Element
        Element.prototype.__proto__ //Node
        Node.prototype.__proto__//EventTarget
        EventTarget.prototype.__proto__//function{}
        EventTarget.prototype.__proto__ === Object.prototype; //true
        EventTarget.prototype.__proto__.__proto__//null
        

    </script>
</body>
</html>